$gap: 15px;
$gap-small: 8px;

.markdown{
    &.small{
        font-size: 13px;

        @for $item from 1 through 7 {
            h#{$item}{
                margin-top: (7-$item)*2px;
                margin-bottom: (7-$item)*1px;
                font-size: 13px + (7-$item)*1;
            }
        }
        ol, ul{
            margin-left: $gap-small;
            margin-bottom: $gap-small;
            li{
                margin-left: 10px;
                line-height: 1.3;
                margin-bottom: 2px;
            }
        }
        pre{
            margin-bottom: $gap-small;
            font-size: 10px;
            padding: $gap-small $gap-small + 5;
            code{
                padding: 0;
                font-family: "JetBrainsMonoDiary";
                background-color: $bg-light;
            }
        }
    }
    line-height: 1.6;
    color: $text-content;
    font-size: 15px;

    hr{
        height: 1px;
        background-color: $color-border;
        width: 100%;
        margin: 20px 0;
    }

    > p{
        //text-indent: 2rem;
        line-height: 1.5;
        margin-bottom: 10px;
    }

    img{
        border: 1px solid $color-border;
        max-width: 100%;
        background-color: white;
        @include border-radius(3px);
    }

    @for $item from 1 through 7 {
        h#{$item}{
            margin-top: (7-$item)*5px;
            margin-bottom: (7-$item)*2px;
            font-size: 14px + (7-$item)*1.5;
        }
    }

    pre{
        line-height: 1.3;
        margin-bottom: $gap;
        font-size: $fz-small;
        padding: $gap $gap + 5;
        background-color: $bg-light;
        width: 100%;
        font-family: "JetBrainsMonoDiary", Consolas;
        overflow-x: auto;
        > code{
            padding: 0;
        }
    }

    code{
        padding: 2px 5px;
        font-size: 13.5px;
        color: #333;
        font-family: "JetBrainsMonoDiary", Consolas;
        background-color: $bg-light;
        @include border-radius(2px);
    }

    table{
        margin-bottom: $gap;
        border: 1px solid $color-border;
        tr{
            th{
                text-align: left;
                min-width: 50px;
                padding: 4px 10px;
                border: 1px solid $color-border;
                background-color: $bg-light;
                &[align=left]{
                    text-align: left;
                }
                &[align=right]{
                    text-align: right;
                }
                &[align=center]{
                    text-align: center;
                }
            }
            td{
                text-align: left;
                border: 1px solid $color-border;
                padding: 3px 10px;
                &[align=left]{
                    text-align: left;
                }
                &[align=right]{
                    text-align: right;
                }
                &[align=center]{
                    text-align: center;
                }
            }
        }
    }

    input[type=checkbox]{
        display: inline-block;
        -webkit-appearance: checkbox !important;
    }

    ol, ul{
        margin-left: $gap;
        margin-bottom: $gap;
        li{
            margin-left: 20px;
            line-height: 1.5;
            margin-bottom: 2px;
        }
    }
    blockquote{
        margin-top: 15px;
        margin-bottom: 15px;
        padding-top: 10px;
        padding-bottom: 10px;
        border-left: 3px solid transparentize(black, 0.8);
        padding-left: 18px;
        background-color: #f5f5f5;
        > *:last-child{
            margin-bottom: 0;
        }
    }

    a{
        color: $orange;
        text-decoration: underline;
    }
}

@media (prefers-color-scheme: dark) {
    .markdown{
        hr{
            background-color: $dark-border-active;
        }
        @for $item from 1 through 7 {
            h#{$item}{
                color: $dark-text-title;
            }
        }
        color: $dark-text;
        p{
            color: $dark-text;
        }
        img{
            padding: 5px;
            border-color: $dark-border;
            background-color: $dark-bg-dark;
        }

        pre{
            background-color: $dark-bg-dark;
            code{
                background-color: $dark-bg-dark;
            }
        }
        code{
            color: $dark-text;
            background-color: $dark-bg-dark;
        }
        table{
            border: 1px solid $dark-border;
            tr{
                th{
                    color: $dark-text-title;
                    border: 1px solid $dark-border;
                    background-color: $dark-bg-dark;
                }
                td{
                    color: $dark-text;
                    border: 1px solid $dark-border;
                }
            }
        }

        ul{
            li{
                color: $dark-text;
            }
        }
        ol{
            li{
                color: $dark-text;
            }
        }
        blockquote{
            background-color: $dark-bg;
            border-left: 3px solid darken(white, 60%);
        }
        a{
            color: $dark-text-title;
        }
    }
}
